package com.edu.exam.enums;

/**
 * 成绩审核操作级别枚举
 *
 * @author System
 * @version 1.0.0 */
public enum GradeAuditOperationLevel {
    /** 信息 */
    INFO("INFO", "信息"),
    /** 警告 */
    WARNING("WARNING", "警告"),
    /** 错误 */
    ERROR("ERROR", "错误"),
    /** 严重 */
    CRITICAL("CRITICAL", "严重"),
    /** 致命 */
    FATAL("FATAL", "致命"),
    /** 调试 */
    DEBUG("DEBUG", "调试"),
    /** 跟踪 */
    TRACE("TRACE", "跟踪");
    
    private final String code;
    private final String description;
    
    GradeAuditOperationLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    public static GradeAuditOperationLevel fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeAuditOperationLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
    
    public static GradeAuditOperationLevel fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeAuditOperationLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }
    
    @Override
    public String toString() {
        return description;
    }
}